home *** CD-ROM | disk | FTP | other *** search
- #include "Painterly.h"
-
- /* The one shell global we need */
- extern MenuHandle gShellMenuHandles[];
-
- /* Painterly Globals */
- MenuHandle gPaintMenuHandles[kNumPaintMenus]; /* The menus we add to the shell */
- DocumentRecord gSrcDoc, gDstDoc; /* The doc records */
- CWindowPtr gSrcWindPtr, gDstWindPtr; /* pointers to the windows, for convenience */
- CWindowPtr gUndoTarget = nil; /* pointer to the window where the last undo operation happened */
- GWorldPtr gUndoBuffer; /* a buffer to allow undo */
- Handle gCurrentBrushHandle = nil; /* handle to the current Brush code */
- short gCurrentBrushNum; /* the current Brush menu item */
- BrushParams gBrushStuff; /* the parameter structure for brush calls */
- Point gNextPoint = {0, 0}; /* the next point touched in ordered strokes */
- short gOrderedIncrement = 16; /* the number of pixels to skip in ordered strokes */
- Boolean gPaintingNow = false, gRandomStrokes = true; /* State Booleans */
- THPrint gPrintRecHandle; /* The print record */
- RGBColor gBGColor = {32767, 32767, 32767}; /* The bg color of the destination window */
- short gDocTitleHeight, gDocFrameWidth; /* Window Stats, for use in positioning
- and growing the windows */
-
- /* Called by the Shell at startup time */
- Boolean AppInit(void)
- {
- /* Init only happens once, so I put this routine in a separate segment */
- return PaintInit();
- }
-
- /* Called when the shell receives an Activate event. It just hides the scrollbars and
- the grow box on de-activate, or shows them on activate.
-
- **Note: I used to do lots of fancy stuff here, like calling ValidRect on the control
- rects to avoid redrawing in the AppUpdate routine, but I just got in trouble. This is
- easier, if not quite as efficient, and cosmetically it's fine (you can't tell if the
- scrollbar gets drawn twice by looking at it). */
-
- void AppActivate(WindowPtr wind, Boolean activate)
- {
- DocumentPeek doc;
-
- if(IsAppWindow(wind) == true)
- {
- doc = (DocumentPeek)wind;
- SetPort(wind);
- if(activate) // an activate event
- {
-
- /* the growbox and controls must be redrawn on activation. */
- DrawGrowIcon(wind);
- ShowControl(doc->hScroll);
- ShowControl(doc->vScroll);
- }
- else // a deactivate event
- {
- /* the growbox and controls must be redrawn on de-activation, too. */
- HideControl(doc->hScroll);
- HideControl(doc->vScroll);
- DrawGrowIcon(wind);
- }
- }
- }
-
- /* Called when a window needs updating. BeginUpdate() has already been called, and the
- port is set to the appropriate window */
- void AppUpdate(EventRecord *event)
- {
- WindowPtr wind;
- Rect updateRect;
-
- wind = (WindowPtr)event->message;
-
- /* Close up the clip to exclude the scroll bars before drawing content */
- CloseClip(wind);
- updateRect = (*wind->clipRgn)->rgnBBox;
- OffToWindow(wind, &updateRect);
-
- /* Reset the clip */
- ClipRect(&wind->portRect);
-
- /* Draw the growbox and controls */
- DrawGrowIcon(wind);
- if(FrontWindow() == wind)
- {
- UpdtControl(wind, wind->visRgn);
- }
-
- }
-
- /* Called when the shell recieves a null event. Here's where painting happens if Auto-
- Paint is on. */
- void AppIdle(EventRecord *Event)
- {
- /* Check if we are painting */
- if(gPaintingNow)
- {
- Rect offRect;
-
- /* Get the rect of the destination */
- offRect = gDstDoc.world->portRect;
-
- if(gRandomStrokes)
- {
- Point pt;
-
- /* Get a Random point in the offRect */
- pt.h = abs(Random() % (offRect.right - offRect.left));
- pt.v = abs(Random() % (offRect.bottom - offRect.top));
-
- /* Stroke it */
- StrokeBoth(pt);
- }
- else /* Ordered Strokes */
- {
- /* Stroke the previously saved next point */
- StrokeBoth(gNextPoint);
-
- /* Increment the point for next time */
- gNextPoint.h += gOrderedIncrement;
-
- /* if we fell off the right edge, wrap around. If we're done, stop painting */
- if(gNextPoint.h >= offRect.right)
- {
- gNextPoint.h = 0;
- gNextPoint.v += gOrderedIncrement;
- if(gNextPoint.v >= offRect.bottom) /* Need to stop painting */
- DoPaintMenu(iStartPainting);
- }
- }
- }
- }
-
- /* Called when there is a click in the content of a window. The port is already set to
- the window, and thePt is in local coords. Manual painting happens here, as does scroll
- bar stuff. */
- void AppClick(Point thePt, WindowPtr whichWindptr, Boolean doubleClick)
- {
- if(IsAppWindow(whichWindptr) == true)
- {
- Point lastPoint = {0, 0}, newPt;
- short part, value;
- ControlHandle control;
- DocumentPeek doc;
-
- /* Get the doc */
- doc = (DocumentPeek)whichWindptr;
-
- /* First find out if the click is in a scrollbar: if so deal with it */
- part = FindControl(thePt, whichWindptr, &control);
- if(part != 0)
- {
- switch ( part )
- {
- /* The thumb is special, and doesn't use the Action Proc */
- case inThumb:
- value = GetCtlValue(control);
- part = TrackControl(control, thePt, nil);
- if ( part != 0 ) /* Good control hit */
- {
- value -= GetCtlValue(control);
- /* value now has CHANGE in value; if value changed, scroll */
- if ( value != 0 )
- if ( control == doc->vScroll )
- ScrollPict(0, value, whichWindptr);
- else
- ScrollPict(value, 0, whichWindptr);
- }
- break;
-
- default: /* they clicked in an arrow, so track & scroll */
- value = TrackControl(control, thePt, (ProcPtr) ScrollActionProc);
- break;
- }
- }
- else /* Not a control click: Paint instead */
- {
- /* Allow an Undo */
- SetUpForUndo(gDstWindPtr);
-
- /* Keep painting while the mouse is down */
- while(StillDown())
- {
- /* Get the mouse location */
- SetPort(whichWindptr);
- GetMouse(&newPt);
-
- /* If the mouse hasn't moved, do nothing */
- if(newPt.h == lastPoint.h && newPt.v == lastPoint.v)
- continue;
-
- /* Set lastPoint for future comparison */
- lastPoint = newPt;
-
- /* Randomize point a little */
- newPt.h += Random() % 8;
- newPt.v += Random() % 8;
-
- /* If the point is outside the world now, do nothing */
- if(!PtInRect(newPt, &doc->world->portRect))
- continue;
-
- /* Stroke it. Need to convert to GWorld coords first*/
- newPt.h += GetCtlValue(doc->hScroll);
- newPt.v += GetCtlValue(doc->vScroll);
- StrokeBoth(newPt);
- }
- }
- }
- }
-
- /* Called when there is a click in the grow region. Just grows the window, with the
- maximum size set to the offscreen size. */
- void AppGrowWindow(WindowPtr wind, Point where, Rect *desk)
- {
- Rect limits;
- DocumentPeek doc;
- GWorldPtr world;
- long size;
-
- /* Do nothing if not our window */
- if(IsAppWindow(wind) == false)
- return;
-
- doc = (DocumentPeek)wind;
- world = doc->world;
-
- /* Set up size limits */
- limits.top = limits.left = kMinWindowSize; /* One inch minimum */
- /* These are actually bigger than the maximum size of the portRect,
- since the outline dragged by GrowWindow is the outline of the window frame,
- not its portRect */
- limits.right = world->portRect.right + kScrollAdjust + gDocFrameWidth;
- limits.bottom = world->portRect.bottom + kScrollAdjust + gDocFrameWidth;
-
- /* Let the user grow the window */
- size = GrowWindow(wind, where, &limits);
-
- /* If the size changed, then erase the scrollbars and grow box area and size the
- window, adjusting the scroll bars and so on */
- if(size != 0)
- {
- Rect tempRect;
- short hSize, vSize;
-
- SetPort(wind);
-
- /* Should erase the scrollbars and grow box area before resizing the window: */
-
- /* make a rect for the growBox */
- tempRect = wind->portRect;
- tempRect.top = tempRect.bottom - kScrollAdjust;
- tempRect.left = tempRect.right - kScrollAdjust;
-
- /* Erase it and the scroll bars */
- EraseRect(&tempRect);
- HideControl(doc->hScroll);
- HideControl(doc->vScroll);
-
- /* OK, size it, but first make sure that the size is within limits (users
- can hold down the command key to bypass the limit, but we won't let 'em).
- Note that we subtract 1 from the limits to account for the window frame */
- hSize = LoWord(size);
- vSize = HiWord(size);
- if(hSize > limits.right - 1) hSize = limits.right - gDocFrameWidth;
- if(vSize > limits.bottom - 1) vSize = limits.bottom - gDocFrameWidth;
- SizeWindow(wind, hSize, vSize, true);
- ClipRect(&wind->portRect);
-
- /* adjust scrollBars */
- AdjustScrollbars(wind, true);
-
- /* re-show controls if in the front */
- if(FrontWindow() == wind)
- {
- ShowControl(doc->hScroll);
- ShowControl(doc->vScroll);
- }
-
- /* Make sure a redraw happens */
- InvalRect(&wind->portRect);
- }
- }
-
- /* Called when the user clicks in the zoom box of a window. It calls a routine to find
- and install the appropriate zoom rect, then zooms it, adjusting the scroll bars and so
- on */
- void AppZoomWindow(WindowPtr wind, short zoomDir)
- {
- Rect worldRect;
- DocumentPeek doc;
-
- /* Do nothing if not our window */
- if(IsAppWindow(wind) == false)
- return;
-
- doc = (DocumentPeek)wind;
- /* Get the maximum size of the window, and set up the window for the zoom */
- worldRect = doc->world->portRect; /* top left is always 0, 0 */
- ReadyWZoom(wind, zoomDir, worldRect.right + kScrollAdjust, worldRect.bottom + kScrollAdjust);
-
- /* Ok, zoom that sucker. Erase the window completely first: cosmetically this looks
- good */
- SetPort(wind);
- EraseRect(&wind->portRect);
- ZoomWindow(wind, zoomDir, true);
- ClipRect(&wind->portRect);
- InvalRect(&wind->portRect);
-
- /* Reset scroll bars, etc, hiding them first to avoid unnecessary drawing. We are
- assuming here that the window is in front (it has to be to be zoomed */
- HideControl(doc->hScroll);
- HideControl(doc->vScroll);
- AdjustScrollbars(wind, true);
- ShowControl(doc->hScroll);
- ShowControl(doc->vScroll);
- }
-
- /* Called when there is a click in the menu bar, before the menu is shown. This is
- the app's opportunity to enable and disable menu items. */
- void AppAdjustMenus()
- {
- MenuHandle mhndl;
- long pictSize, ignored;
- Boolean windowsUp;
-
- /* OK, first the file menu. If the windows are up, then enable Close, Save (if
- the window needs saving), and Save As. Also enable Page Setup and Print if
- the print record exists. If there are no windows open, disable same. Open
- and Quit are always enabled. */
-
- windowsUp = ((WindowPeek)gSrcWindPtr)->visible;
- mhndl = gShellMenuHandles[kFileMenu];
- if(windowsUp)
- {
- EnableItem(mhndl, iClose);
- if(((DocumentPeek)FrontWindow())->dirty)
- EnableItem(mhndl, iSave);
- else
- DisableItem(mhndl, iSave);
- EnableItem(mhndl, iSaveAs);
- if(gPrintRecHandle != nil)
- {
- EnableItem(mhndl, iPageSetup);
- EnableItem(mhndl, iPrint);
- }
- }
- else /* The windows are closed */
- {
- DisableItem(mhndl, iClose);
- DisableItem(mhndl, iSave);
- DisableItem(mhndl, iSaveAs);
- DisableItem(mhndl, iPageSetup);
- DisableItem(mhndl, iPrint);
- }
-
- /* Now the Edit Menu. If the windows are up, enable Cut, Copy, and Clear
- automatically, and Undo and Paste conditionally. Otherwise, disable everything */
-
- mhndl = gShellMenuHandles[kEditMenu];
- if(windowsUp)
- {
- EnableItem(mhndl, iCut);
- EnableItem(mhndl, iCopy);
- EnableItem(mhndl, iClear);
-
- /* For Paste: have to see if there is a PICT in the scrap */
- pictSize = GetScrap(nil, 'PICT', &ignored);
- if(pictSize > 0) /* We have a PICT in the scrap */
- EnableItem(mhndl, iPaste);
- else
- DisableItem(mhndl, iPaste);
-
- /* Now Undo: have to see if the undo buffer exists and a target exists */
- if(gUndoBuffer != nil && gUndoTarget != nil) /* We have a buffer and a target */
- EnableItem(mhndl, iUndo);
- else
- DisableItem(mhndl, iUndo);
- }
- else
- {
- DisableItem(mhndl, iUndo);
- DisableItem(mhndl, iCut);
- DisableItem(mhndl, iCopy);
- DisableItem(mhndl, iPaste);
- DisableItem(mhndl, iClear);
- }
- }
-
- /* called when a menu other than Apple, File, or Edit is used. */
- void AppMenu(short id, short item)
- {
- switch(id)
- {
- case kFilterMenuID:
- DoFilterMenu(item);
- break;
-
- case kBrushMenuID:
- DoBrushMenu(item);
- break;
-
- case kAutoPaintMenuID:
- DoPaintMenu(item);
- break;
-
- default:
- break;
- }
- }
-
- /* Called when the user selects "Open" from the File menu. In this app, opening a
- PICT file always puts the PICT into the source window, and clears the destination */
- void AppOpen(void)
- {
- SFTypeList typeList;
- short numTypes, err;
- StandardFileReply reply;
-
- /* Close any windows that might be open now: if the user aborts a save, do nothing */
- if(AppClose() == false)
- return;
-
- /* only show PICT files */
- typeList[0] = 'PICT';
-
- /* Standard File Dialog, system 7 style */
- StandardGetFile(nil, 1, typeList, &reply);
-
- /* If they clicked "open"... */
- if(reply.sfGood == true)
- {
- /* A big gnarly routine that sets everything up and reads in the pict */
- err = ReadPICTFileToNewWorlds(&reply.sfFile);
- if(err == noErr)
- {
- /* Restart the brush, to make sure there are no out of date values
- in the storage */
- err = SetCurrentBrush(gCurrentBrushNum);
- if(err != noErr)
- DoErrorAlert(kGenericErrorStr, err);
- }
- else
- DoErrorAlert(kBadReadStr, err);
- }
- }
-
-
- /* Called when the user selects "Close" from the File menu, chooses "Open" with a
- doc already open, or clicks the close box of a window. */
- Boolean AppClose(void)
- {
- Boolean rslt = false;
-
- /* Since the windows are in pairs, need to hide both of them. Note that we don't
- throw them away, just hide them */
- if(SaveCurrentDocs())
- {
- HideWindow(gSrcWindPtr);
- HideWindow(gDstWindPtr);
-
- /* Turn off painting if it's on */
- if(gPaintingNow == true)
- DoPaintMenu(iStartPainting);
-
- /* Throw away the GWorlds to free up memory. */
- KillGlobalGWorlds();
-
- /* Disable the appropriate menus */
- DisableItem(gPaintMenuHandles[kFilterMenu], 0);
- DisableItem(gPaintMenuHandles[kBrushMenu], 0);
- DisableItem(gPaintMenuHandles[kAutoPaintMenu], 0);
- DrawMenuBar();
-
- rslt = true;
- }
- return rslt;
- }
-
- /* Called when the user selects "Save" from the File menu. Returns a boolean that is
- true only if AppSaveAs() is called and the user cancels the save, or if there is an
- error. */
- Boolean AppSave(void)
- {
- DocumentPeek doc;
- OSErr err = noErr;
- Boolean canceled = false;
- WindowPtr wind;
-
- /* Do nothing if the front window isn't ours */
- wind = FrontWindow();
- if(IsAppWindow(wind) == false)
- return false;
-
- /* Get the window in question */
- doc = (DocumentPeek)wind;
-
- /* Check the file name in our window's spec. If empty, do save as, else save */
- if(*doc->fileSpec.name == 0)
- {
- canceled = AppSaveAs();
- }
- else /* a regular save, it's been saved before */
- {
- /* Write the pict to the file */
- err = WorldToExistingFile(&doc->fileSpec, doc->world);
- /* It's possible that the user switched to the finder and deleted the
- file or ejected the disk it's on, so let's check the error. If it's
- fnfErr or nsvErr, do a SaveAs */
- if(err == fnfErr || err == nsvErr)
- {
- err = noErr;
- canceled = AppSaveAs();
- }
-
- if(err == noErr)
- /* Successful save, so set dirty flag to false */
- doc->dirty = false;
- else
- {
- canceled = true;
- if(err == memFullErr)
- DoErrorAlert(kNoMemStr, 0);
- else
- DoErrorAlert(kBadWriteStr, err);
- }
- }
- return canceled;
- }
-
- /* Called when the user selects "Save As..." from the File menu. Returns a boolean that
- is true only if the user cancels the save. */
- Boolean AppSaveAs(void)
- {
- DocumentPeek doc;
- Str255 title, prompt;
- short promptID;
- StandardFileReply reply;
- OSErr err = noErr;
- Boolean canceled = false;
-
- if(IsAppWindow(FrontWindow()) == false)
- return canceled;
-
- /* Get the window we are saving and its title, and select the appropriate prompt */
- doc = (DocumentPeek)FrontWindow();
- GetWTitle((WindowPtr)doc, title);
- if(doc == &gSrcDoc)
- promptID = kSrcSavePrompt;
- else
- promptID = kDstSavePrompt;
-
- /* put up Standard File Dialog */
- StandardPutFile(TheStr(prompt, promptID), title, &reply);
-
- /* If user clicked Save, do it */
- if(reply.sfGood == true)
- {
- /* If we are replacing an existing file, we call one routine, if we are
- creating a new one, another routine */
- if(reply.sfReplacing)
- err = WorldToExistingFile(&reply.sfFile, doc->world);
- else
- err = WorldToNewFile(&reply.sfFile, doc->world);
-
- if(err == noErr)
- {
- /* Successful save, so copy our file spec into the window info,
- rename the window, and set the dirty flag */
- doc->fileSpec = reply.sfFile;
- SetWTitle((WindowPtr)doc, reply.sfFile.name);
- doc->dirty = false;
- }
- }
- else
- canceled = true;
-
- if(err != noErr)
- {
- canceled = true;
- if(err == memFullErr)
- DoErrorAlert(kNoMemStr, 0);
- else
- DoErrorAlert(kBadWriteStr, err);
- }
-
- return canceled;
- }
-
- /* Called when the user selects "Page Setup..." from the File menu. */
- void AppPageSetup(void)
- {
- short err;
- long size, grow;
-
- if(gPrintRecHandle != nil)
- {
- PrOpen(); /* Open Print Mgr */
- err = PrError(); /* Check for errors */
- if(err == noErr)
- {
- PrStlDialog(gPrintRecHandle); /* Do the style dialog */
- }
- PrClose(); /* Close Print Mgr */
- }
- }
-
- /* Called when the user selects "Print..." from the File menu. */
- void AppPrint(void)
- {
- GWorldPtr world;
-
- /* Do nothing if the front window isn't ours, or if there is no print record */
- if(IsAppWindow(FrontWindow()) == false || gPrintRecHandle == nil)
- return;
-
- world = ((DocumentPeek)FrontWindow())->world;
- Print(world);
- }
-
- /* Called when the user selects "Undo" from the Edit menu. */
- void AppUndo(void)
- {
- DocumentPeek doc;
- GWorldPtr tempWorld;
-
- if(gUndoBuffer == nil || gUndoTarget == nil)
- return;
-
- /* Get the target Doc */
- doc = (DocumentPeek)gUndoTarget;
-
- /* Swap the worlds: gUndoBuffer gets attached to the doc, the doc's
- world becomes the new gUndoBuffer */
- tempWorld = doc->world;
- doc->world = gUndoBuffer;
- gUndoBuffer = tempWorld;
-
- /* Update the Brush Params */
- if(doc == &gSrcDoc)
- gBrushStuff.theSource = doc->world;
- else
- gBrushStuff.theDestination = doc->world;
-
- /* Update the window */
- SetPort(gUndoTarget);
- InvalRect(&gUndoTarget->portRect);
- }
-
- /* Called when the user selects "Cut" from the Edit menu. */
- void AppCut(void)
- {
- DocumentPeek doc;
- WindowPtr wind;
-
- /* Do nothing if the front window isn't ours */
- wind = FrontWindow();
- if(IsAppWindow(wind) == false)
- return;
-
- /* First copy pict to clipboard */
- if(AppCopy() == noErr)
- {
- /* Allow an undo of the cut */
- SetUpForUndo(wind);
-
- /* Then clear the off world and request a window update */
- doc = (DocumentPeek)wind;
- if(doc->world != nil)
- {
- EraseOff(doc->world);
- }
-
- doc->dirty = false; /* assume no one wants to save an empty picture */
- SetPort(wind);
- InvalRect(&wind->portRect);
- }
- }
-
- /* Called when the user selects "Copy" from the Edit menu. */
- OSErr AppCopy(void)
- {
- PicHandle pict;
- DocumentPeek doc;
- long length;
- OSErr err = -1;
- WindowPtr wind;
-
- /* Do nothing if the front window isn't ours */
- wind = FrontWindow();
- if(IsAppWindow(wind) == false)
- return noErr;
-
- /* Get the window we are copying from, and its off world */
- doc = (DocumentPeek)wind;
-
- if(doc->world != nil)
- {
- err = ZeroScrap();
- if(err == noErr)
- {
- err = -1; /* reset error */
- /* Convert GWorld to a pict */
- pict = WorldToPict(doc->world);
- if(pict != nil)
- {
- /* Figure out how big the pict is */
- length = GetHandleSize(pict);
- HLock(pict);
-
- /* Put it in the clipboard */
- err = PutScrap(length, 'PICT', *pict);
- HUnlock(pict);
- KillPicture(pict);
- }
- else
- err = memFullErr;
- }
- }
- if(err != noErr)
- {
- if(err == memFullErr)
- DoErrorAlert(kNoMemStr, 0);
- else
- DoErrorAlert(kGenericErrorStr, err);
- }
- return err;
- }
-
- /* Called when the user selects "Paste" from the Edit menu. */
- void AppPaste(void)
- {
- PicHandle pict;
- Rect frame;
- DocumentPeek doc;
- long length, dum;
- WindowPtr wind;
- CGrafPtr oldport;
- GDHandle olddev;
-
- /* Do nothing if the front window isn't ours */
- wind = FrontWindow();
- if(IsAppWindow(wind) == false)
- return;
-
- /* Save the current port and device */
- GetGWorld(&oldport, &olddev);
-
- /* Make a small handle to hold the pict */
- pict = (PicHandle)NewHandle(8L);
- if(pict != nil)
- {
- /* Get the pict from the clipboard */
- length = GetScrap(pict, 'PICT', &dum);
- if(length > 0) /* got something */
- {
- /* Get the doc we are pasting into */
- doc = (DocumentPeek)wind;
-
- /* Allow an undo */
- SetUpForUndo(wind);
-
- /* Draw the picture */
- SetGWorld(doc->world, nil);
- frame = (**pict).picFrame;
- DrawPicture(pict, &frame);
-
- /* Set the dirty flag for the window we pasted into to true, and
- Inval the port rect so it is updated */
- doc->dirty = true;
- SetGWorld(wind, olddev);
- InvalRect(&wind->portRect);
- }
- else
- DoErrorAlert(kGenericErrorStr, 0); /* No pict in clip, or couldn't get it */
- DisposHandle((Handle)pict);
- }
- else
- DoErrorAlert(kNoMemStr, 0);
- }
-
- /* Called when the user selects "Clear" from the Edit menu. */
- void AppClear(void)
- {
- DocumentPeek doc;
- WindowPtr wind;
-
- /* Do nothing if the front window isn't ours */
- wind = FrontWindow();
- if(IsAppWindow(wind) == false)
- return;
-
- doc = (DocumentPeek)wind;
-
- /* Allow an undo */
- SetUpForUndo(wind);
-
- /* clear the off world and request a window update */
- if(doc->world != nil)
- EraseOff(doc->world);
- doc->dirty = false; /* assume no one wants to save an empty picture */
- SetPort(wind);
- InvalRect(&wind->portRect);
- }
-
- /* Called when the user chooses "Quit" from the File menu. If the user cancels
- the save it returns false, otherwise it returns true and the shell quits */
- Boolean AppQuit(void)
- {
- /* returns false if the user cancels the save at any point, or if there is an error
- saving */
- return SaveCurrentDocs();
- }
-
- /* Called when the shell is about to quit, Just deallocates memory. */
- void AppCleanUp(void)
- {
- /* Unload the current brush */
- if(gCurrentBrushHandle != nil)
- {
- CallBrush(kStopBrush, &gBrushStuff, gCurrentBrushHandle);
- ReleaseResource(gCurrentBrushHandle);
- gBrushStuff.storage = (long)nil;
- }
-
- /* Kill the GWorlds */
- KillGlobalGWorlds();
-
- /* Kill the print record, if there is one */
- if(gPrintRecHandle != nil)
- DisposHandle(gPrintRecHandle);
-
- /* Close the windows, which also kills the scrollBars */
- if(gSrcWindPtr != nil)
- CloseWindow(gSrcWindPtr);
- if(gDstWindPtr != nil)
- CloseWindow(gDstWindPtr);
- }
-
-
-